LIBRARIES

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✔ ggplot2 3.3.6     ✔ purrr   0.3.4
## ✔ tibble  3.1.7     ✔ dplyr   1.0.9
## ✔ tidyr   1.2.0     ✔ stringr 1.4.0
## ✔ readr   2.1.2     ✔ forcats 0.5.1
## Warning: package 'ggplot2' was built under R version 4.2.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(sf)
## Linking to GEOS 3.9.1, GDAL 3.3.2, PROJ 7.2.1; sf_use_s2() is TRUE
library(tidycensus)
## Warning: package 'tidycensus' was built under R version 4.2.1
library(tmap)

PART 1 - DATA EXPLORATION!

STORES DATA - SAFEGRAPH PLACES

places <- st_read("Data/GA_MSA_pts.gpkg")
## Reading layer `GA_MSA_pts' from data source 
##   `C:\Users\pball24\My Drive\Patrick Academic\PDRA\Projects\CARTO SDSC 2022\CARTO-SDSC2022\Data\GA_MSA_pts.gpkg' 
##   using driver `GPKG'
## Simple feature collection with 74345 features and 5 fields
## Geometry type: POINT
## Dimension:     XY
## Bounding box:  xmin: -85.3491 ymin: 32.84559 xmax: -83.28591 ymax: 34.56562
## Geodetic CRS:  WGS 84

Look at the attributes:

glimpse(places)
## Rows: 74,345
## Columns: 6
## $ top_category  <chr> "Accounting, Tax Preparation, Bookkeeping, and Payroll S…
## $ sub_category  <chr> "Other Accounting Services", "Other Accounting Services"…
## $ brands        <chr> "", "", "", "", "", "", "", "", "", "", "", "", "", "", …
## $ location_name <chr> "Bookkeeping by Andrea", "Pereira and Company CPA", "Bra…
## $ MSA           <chr> "Atlanta-Sandy Springs-Alpharetta, GA", "Atlanta-Sandy S…
## $ geom          <POINT [°]> POINT (-84.26228 34.12522), POINT (-84.50167 33.94…

Let’s take a look at the distribution of grocery stores:

grocery <- places %>%
  filter(top_category == "Grocery Stores") %>%
  mutate(brands = case_when(brands == "" ~ "Unclassified",
                              TRUE ~ brands))
tmap_mode("view")
## tmap mode set to interactive viewing
tm_shape(grocery) +
  tm_dots(col = "brands", size = 0.05)

US GEODEMOGRAPHIC CLASSIFICATION

geodemo <- st_read("Data/GA_GD.gpkg")
## Reading layer `GA_GD' from data source 
##   `C:\Users\pball24\My Drive\Patrick Academic\PDRA\Projects\CARTO SDSC 2022\CARTO-SDSC2022\Data\GA_GD.gpkg' 
##   using driver `GPKG'
## Simple feature collection with 1021 features and 3 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -85.38658 ymin: 32.84464 xmax: -83.2692 ymax: 34.61792
## Geodetic CRS:  WGS 84
glimpse(geodemo)
## Rows: 1,021
## Columns: 4
## $ GEOID      <chr> "01029959500", "01029959800", "01111000200", "01111000400",…
## $ TractGroup <chr> "C: Middle Income, Single Family Homes", "C: Middle Income,…
## $ MSA        <chr> "Atlanta-Sandy Springs-Alpharetta, GA", "Atlanta-Sandy Spri…
## $ geom       <MULTIPOLYGON [°]> MULTIPOLYGON (((-85.3863 33..., MULTIPOLYGON (…
tm_shape(geodemo) +
  tm_fill(col = "TractGroup", alpha = 0.5) +
  tm_borders(col = "black", lwd = 0.5)

POPULATION DATA

census_api_key("e0f3cdfa0e1e13ab3a4d9dc32c67984d0be5523b")
## To install your API key for use in future sessions, run this function with `install = TRUE`.
pop <- get_decennial(geography = "Tract", variables = "P001001",
                     state = "GA", year = 2010)
## Getting data from the 2010 decennial Census
## Using Census Summary File 1
glimpse(pop)
## Rows: 1,969
## Columns: 4
## $ GEOID    <chr> "13021012800", "13021013102", "13021012600", "13021012700", "…
## $ NAME     <chr> "Census Tract 128, Bibb County, Georgia", "Census Tract 131.0…
## $ variable <chr> "P001001", "P001001", "P001001", "P001001", "P001001", "P0010…
## $ value    <dbl> 3260, 4340, 4171, 2184, 1837, 6119, 6034, 2952, 4420, 4229, 4…
gd_pop <- merge(geodemo, pop, by = "GEOID")
glimpse(gd_pop)
## Rows: 1,016
## Columns: 7
## $ GEOID      <chr> "13013180103", "13013180104", "13013180105", "13013180106",…
## $ TractGroup <chr> "C: Middle Income, Single Family Homes", "C: Middle Income,…
## $ MSA        <chr> "Atlanta-Sandy Springs-Alpharetta, GA", "Atlanta-Sandy Spri…
## $ NAME       <chr> "Census Tract 1801.03, Barrow County, Georgia", "Census Tra…
## $ variable   <chr> "P001001", "P001001", "P001001", "P001001", "P001001", "P00…
## $ value      <dbl> 4668, 2016, 2501, 2624, 3854, 2931, 3187, 2416, 4042, 2887,…
## $ geometry   <MULTIPOLYGON [°]> MULTIPOLYGON (((-83.79352 3..., MULTIPOLYGON (…

Let’s take a look at the population distribution of Atlanta MSA:

tm_shape(gd_pop) +
  tm_fill(col = "value", alpha = 0.5, style = "jenks") +
  tm_borders(col = "black", lwd = 0.5)

PART 2 - CATCHMENT ANALYSIS

PART 3 - CATCHMENT PROFILING